import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:remixicon/remixicon.dart';
import 'package:super_person_app/components/cache_widget.dart';
import 'package:super_person_app/components/chart_item.dart';

import 'message_logic.dart';

class MessagePage extends StatelessWidget {
  const MessagePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final logic = Get.find<MessageLogic>();
    final state = Get.find<MessageLogic>().state;

    return CacheWidget(
      child: SafeArea(
        child: Scaffold(
          appBar: AppBar(
            centerTitle: true,
            backgroundColor: Colors.white,
            elevation: 0,
            title: Text(
              "消息",
              style: TextStyle(
                color: const Color(0xff212121),
                fontSize: 16.sp, fontWeight: FontWeight.w600,
              ),
            ),
            leading: IconButton(
              color: const Color(0xff414442),
              icon: Icon(Remix.contacts_line, size: 20.sp),
              onPressed: () {
                Get.back();
              },
            ),
            actions: [
              IconButton(
                color: const Color(0xff414442),
                icon: Icon(Remix.add_line, size: 26.sp),
                onPressed: () {
                  Get.back();
                },
              ),
            ],
          ),
          body: ListView(
            children: [
              _searchWrapper(),
              ChartItem(
                avatar: "https://p26-passport.byteacctimg.com/img/user-avatar/b06e7ba412d503a0d2d1ae6decb3c224~300x300.image",
                title: "富通好旺角业主群",
                time: "12:13",
                sub: "好旺角业委会客服-张三：您反馈的问题我们会一直跟踪",
                onTap: () {
                  Get.toNamed("/message/chart");
                },
              ),
              const ChartItem(
                avatar: "https://p26-passport.byteacctimg.com/img/user-avatar/c828b3d301061f8ea11d695275a4986f~300x300.image",
                title: "Aya_",
                time: "12:13",
                sub: "前端菜鸡也想掌控时间，所以做了一个时间管理小程序",
              ),
              const ChartItem(
                avatar: "https://p6-passport.byteacctimg.com/img/user-avatar/6aa84673e775d886c246d66595a7313b~300x300.image",
                title: "冷漠的麻辣烫",
                time: "12:13",
                sub: "跟着开源项目学GO",
              ),
              const ChartItem(
                avatar: "https://p9-passport.byteacctimg.com/img/user-avatar/73cdbffb1f122e39412a857d5fb73288~300x300.image",
                title: "胡七筒",
                time: "12:13",
                sub: "程序员：疯狂的内卷&无效的抗争",
              ),
              const ChartItem(
                avatar: "https://p3-passport.byteacctimg.com/img/user-avatar/1e2c107ddeb08a121dac8000dad8cd05~300x300.image",
                title: "囧么肥事",
                time: "12:13",
                sub: "同事提出个我从未想过的问题，为什么Kubernetes要”多此一举“推出静态Pod概念？",
              ),
              const ChartItem(
                avatar: "https://p26-passport.byteacctimg.com/img/user-avatar/7971f89bb5266763f2d25cb19701914a~300x300.image",
                title: "看星星的兔子",
                time: "12:13",
                sub: "不同的人，即使站在同一个地方，透过各自的人生，看到的风景也有所不同[思考]",
              ),
              const ChartItem(
                avatar: "https://p3-passport.byteacctimg.com/img/user-avatar/c7db0c8bc7dd2b829cb8415760650780~300x300.image",
                title: "小雨滴滴滴滴滴",
                time: "12:13",
                sub: "好可爱呀！",
              ),
              const ChartItem(
                avatar: "https://p9-passport.byteacctimg.com/img/user-avatar/f9bafb31d605404b1127002c3e6c86f6~300x300.image",
                title: "zyzjy",
                time: "12:13",
                sub: "男生们介意姐弟恋吗？可以接受大几岁？不是不想找同龄人，而是同龄人都不再单身了[捂脸]",
              ),
              const ChartItem(
                avatar: "https://p6-passport.byteacctimg.com/img/user-avatar/171da9811979e7452da971fc0c413e8a~300x300.image",
                title: "山西第一深情",
                time: "12:13",
                sub: "发年终了家人们！",
              ),
              const ChartItem(
                avatar: "https://p3-passport.byteacctimg.com/img/user-avatar/55c3a554558bafab5444ac5707b1a33f~300x300.image",
                title: "用户9972431717641",
                time: "12:13",
                sub: "扬州开发，想找个程序员男朋友94－88，家里催，不介意姐弟恋，最好不抽烟，长相清秀，爱干净扬州周边城市都可以考虑",
              ),
            ],
          ),
        ),
      ),
    );
  }


  Widget _searchWrapper() {
    return Container(
      alignment: Alignment.center,
      padding: EdgeInsets.only(
        left: 16.w,
        right: 16.w,
        top: 10.h,
        bottom: 10.h
      ),
      color: Colors.white,
      child: Container(
        alignment: Alignment.center,
        padding: EdgeInsets.only(
            left: 10.w,
            right: 10.w,
            top: 9.h,
            bottom: 9.h
        ),
        decoration: BoxDecoration(
          color: const Color(0xffF4F4F4).withOpacity(0.8),
          borderRadius: BorderRadius.all(Radius.circular(4.w))
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Icon(Remix.search_line, color: const Color(0xffABABAB), size: 16.sp),
            Text("搜索", style: TextStyle(
              color: const Color(0xffABABAB),
              fontSize: 13.sp
            ))
          ],
        ),
      ),
    );
  }
}
